unit GMedParkStoris;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GForm, cxGraphics, cxPropertiesStore, dxBarExtItems, dxBar,
  cxClasses, ActnList, dxStatusBar, cxControls, cxPC, cxStyles, cxCustomData,
  cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridCustomView,
  cxGrid, cxNavigator, cxDBNavigator, cxContainer, cxGroupBox, cxCalc;

type
  TfMedParkStoris = class(TGamaForm)
    tsSarasas: TcxTabSheet;
    dbgSarasas: TcxGrid;
    dbgSarasasDBTableView: TcxGridDBTableView;
    dbgSarasasLevel1: TcxGridLevel;
    cxGroupBox1: TcxGroupBox;
    dbnNav: TcxDBNavigator;
    dbgSarasasDBTableViewstoris: TcxGridDBColumn;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure LentelesOn;
    procedure LentelesOff;
    //
    procedure MainBeforeInserOrEdit(DataSet: TDataSet);
    procedure MainBeforePost(DataSet: TDataSet);
    procedure MainAfterPostOrDelete(DataSet: TDataSet);
    procedure MainAfterPostOrDeleteOrCancel(DataSet: TDataSet);
    procedure MainPostError(DataSet: TDataSet;
                E: EDatabaseError; var Action: TDataAction);
    procedure MainNewRecord(DataSet: TDataSet);
  public
    { Public declarations }
    procedure RefreshTables; override;
  end;

var
  fMedParkStoris: TfMedParkStoris;

implementation

{$R *.dfm}

uses
  bendri, med_dm, Tools;

procedure TfMedParkStoris.LentelesOn;
begin
  with dmMed do begin
    tbMedParkStoris.BeforeInsert  := self.MainBeforeInserOrEdit;
    tbMedParkStoris.BeforeEdit    := self.MainBeforeInserOrEdit;
    tbMedParkStoris.BeforePost    := self.MainBeforePost;
    tbMedParkStoris.AfterPost     := self.MainAfterPostOrDelete;
    tbMedParkStoris.AfterDelete   := self.MainAfterPostOrDelete;
    tbMedParkStoris.AfterCancel   := self.MainAfterPostOrDeleteOrCancel;
    //tbMedParkStoris.OnPostError   := self.MainPostError;
    tbMedParkStoris.OnNewRecord   := self.MainNewRecord;
  end;
end;

procedure TfMedParkStoris.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  LentelesOff;
end;

procedure TfMedParkStoris.FormShow(Sender: TObject);
begin
  inherited;
  LentelesOn;
end;

procedure TfMedParkStoris.LentelesOff;
begin
  with dmMed do begin
    tbMedParkStoris.BeforeInsert  := nil;
    tbMedParkStoris.BeforeEdit    := nil;
    tbMedParkStoris.BeforePost    := nil;
    tbMedParkStoris.AfterPost     := nil;
    tbMedParkStoris.AfterDelete   := nil;
    tbMedParkStoris.AfterCancel   := nil;
    //tbMedParkStoris.OnPostError   := nil;
    tbMedParkStoris.OnNewRecord   := nil;
  end;
end;

procedure TfMedParkStoris.MainBeforePost(DataSet: TDataSet);
begin
  //MessageText := '';
  //dmBendras.RandomIDBeforePost(DataSet);
end;

procedure TfMedParkStoris.MainPostError(DataSet: TDataSet;
                E: EDatabaseError; var Action: TDataAction);
begin
  //dmBendras.RandomIDPostError(DataSet, E, Action);
end;

procedure TfMedParkStoris.MainNewRecord(DataSet: TDataSet);
begin
  //
end;

procedure TfMedParkStoris.MainAfterPostOrDelete(DataSet: TDataSet);
begin
  dmBendras.ApplyUpdatesAfterPostOrDelete(DataSet);
  MainAfterPostOrDeleteOrCancel(DataSet);
  bRefreshTables := true;
end;

procedure TfMedParkStoris.MainAfterPostOrDeleteOrCancel(DataSet: TDataSet);
begin
  SetControlsEditColor( DataSet, GamaPageControl, false );
end;

procedure TfMedParkStoris.MainBeforeInserOrEdit(DataSet: TDataSet);
begin
  SetControlsEditColor( DataSet, GamaPageControl, true);
end;

procedure TfMedParkStoris.RefreshTables;
begin
  if bRefreshTables then begin
    bRefreshTables := false;
    //dmAlga.tbIssilavLookup.Refresh;
  end
end;

end.
